import request from '@/utils/request'
import { IPage } from '@/@types'
import { PromiseData } from '@/@types/request'
import { IResourceList } from '../type'

// 获取资源列表
export const getResourceHandle = (data: any): Promise<PromiseData<IPage<IResourceList[]>>> =>
  request.post('/resourceCenter/resourceList', data)

// 上传
export const uploadHandle = (formData: FormData) =>
  request.post('/resourceCenter/addDocument?path=uploadFile', formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })

// 下载
export const downLoad = (data: any) => request.post('/common/fileProcessing/getFile', data, { responseType: 'blob' })

// 删除
export const deleteResource = (data: any) => request.post('/resourceCenter/delDocument', data)

// 查看
export const view = (data: any): Promise<Blob> =>
  request.post('/resourceCenter/getFile', data, { responseType: 'blob' })
